package com.healthy.education.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.education.domain.Seminars;
import com.healthy.education.service.ISeminarsService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 研讨会信息Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/Seminars")
public class SeminarsController extends BaseController
{
    @Autowired
    private ISeminarsService seminarsService;

    /**
     * 查询研讨会信息列表
     */
    @RequiresPermissions("education:Seminars:list")
    @GetMapping("/list")
    public TableDataInfo list(Seminars seminars)
    {
        startPage();
        List<Seminars> list = seminarsService.selectSeminarsList(seminars);
        return getDataTable(list);
    }

    /**
     * 导出研讨会信息列表
     */
    @RequiresPermissions("education:Seminars:export")
    @Log(title = "研讨会信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Seminars seminars)
    {
        List<Seminars> list = seminarsService.selectSeminarsList(seminars);
        ExcelUtil<Seminars> util = new ExcelUtil<Seminars>(Seminars.class);
        util.exportExcel(response, list, "研讨会信息数据");
    }

    /**
     * 获取研讨会信息详细信息
     */
    @RequiresPermissions("education:Seminars:query")
    @GetMapping(value = "/{seminarId}")
    public AjaxResult getInfo(@PathVariable("seminarId") Long seminarId)
    {
        return success(seminarsService.selectSeminarsBySeminarId(seminarId));
    }

    /**
     * 新增研讨会信息
     */
    @RequiresPermissions("education:Seminars:add")
    @Log(title = "研讨会信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Seminars seminars)
    {
        return toAjax(seminarsService.insertSeminars(seminars));
    }

    /**
     * 修改研讨会信息
     */
    @RequiresPermissions("education:Seminars:edit")
    @Log(title = "研讨会信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Seminars seminars)
    {
        return toAjax(seminarsService.updateSeminars(seminars));
    }

    /**
     * 删除研讨会信息
     */
    @RequiresPermissions("education:Seminars:remove")
    @Log(title = "研讨会信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{seminarIds}")
    public AjaxResult remove(@PathVariable Long[] seminarIds)
    {
        return toAjax(seminarsService.deleteSeminarsBySeminarIds(seminarIds));
    }
}
